package com.beidouapp.mvc;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import com.beidouapp.service.EmployeeService;

@Controller
@RequestMapping(value = "/im")
public class ImController
{

	@Autowired
	private EmployeeService employeeService;
	@Autowired
	com.beidouapp.manager.IMClient imClient;
	@RequestMapping(value = "xx", method = {RequestMethod.POST})
	public  void xx(HttpServletRequest r,HttpServletResponse resp,@RequestParam MultipartFile imageFile){
		System.out.println();
	}
	@RequestMapping(value = "call", method = {RequestMethod.GET,RequestMethod.POST})
	public  void call(HttpServletRequest r,HttpServletResponse resp,@RequestBody String data){
		String reqMethod=r.getMethod();
		if(RequestMethod.GET.toString().equalsIgnoreCase(reqMethod)){
			try {
				resp.getWriter().print(r.getParameter("echostr"));
				return ;
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
   /*	 	JSONObject json= JSONObject.fromObject(data);
		 	String base64Content= json.getString("content");
		 	String content =Base64.decode(base64Content);
		 	JSONObject contentJSON= JSONObject.fromObject(content);
		 	if(contentJSON.containsKey("msg_type")&& IMClient.SEPCIAL_MSG_TYPE.equals(contentJSON.getString("msg_type"))){
			 	String accept_uid=contentJSON.getString("dest_uid");
			 	String send_uid= contentJSON.getString("source_uid");
			 	imClient.sendMessage(send_uid, accept_uid, content);
		 	}*/
	}
	

}
